package com.three.dao.impl;

import com.three.dao.UserDao;
import com.three.pojo.User;

/**
 * @author wzm
 * @create 2023-11-07 16:46
 * project_name:web2310
 * @Description
 */
//User功能设计接口的实现类  具体把功能实现
public class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    public int insert(User user) {
        //利用baseDao完成功能
        return update("insert into tb_user(username,password) values(?,?)"
                ,user.getUsername(),user.getPassword());
    }

    @Override
    public int delete(Integer id) {
        return 0;
    }

    @Override
    public User selectByUserNameAndPassWord(User user) {
        String sql = "select * from tb_user where username = ? and password = ?";
        //利用工具类BaseDao
        return selectbyOne(User.class,sql,user.getUsername(),user.getPassword());
    }

    @Override
    public User selectExistsName(String username) {
        String sql = "select * from tb_user where username = ?";
        return selectbyOne(User.class,sql,username);
    }
}
